<template>
    <div class="content">
        <el-row :gutter="20">
            <el-col :span="24" class="text-right">
                <el-input v-model="form.search" style="width: 240px" placeholder="请输入关键词" />
                <el-button type="primary" class="ml10" :icon="Search" @click="onSearch">搜索</el-button>
                <el-button type="primary" class="ml10" :icon="RefreshRight" @click="onSearch('Refresh')" />
            </el-col>
        </el-row>
        <div class="text-right"><el-checkbox v-model="form.parentBorder" label="" size="large" /></div>
        <el-table class="mt20" :data="tableData" border v-loading="form.loading" style="width: 100%;font-size: 16px;">
            <el-table-column type="index" :index="indexMethod" label="序号" width="60" />
            <el-table-column prop="type" label="维护结果" width="110"/>
            <el-table-column prop="project_title" label="所属项目" show-overflow-tooltip />
            <el-table-column prop="schedule_title" label="工序名称" show-overflow-tooltip />
            <el-table-column prop="region" label="施工区域" width="100"/>
            <el-table-column prop="floor" label="楼层" width="100"/>
            <el-table-column prop="project_user" label="进度责任人" width="100"/>
            <el-table-column prop="tpm" label="维护方" width="100" />
            <el-table-column prop="tpm_user" label="维护人" width="90" />
            <el-table-column prop="delay" label="推迟原因" width="110" />
            <el-table-column fixed="right" label="操作" width="80">
                <template #default="scope">
                    <el-button link type="primary" @click="onReview(scope.$index)" size="small">审核</el-button>
                </template>
            </el-table-column>
        </el-table>
        <div class="mt20">
            <el-pagination v-model:current-page="form.current" v-model:page-size="form.limit" :page-sizes="[10, 20, 30, 40, 50, 100]" layout="total, sizes, prev, pager, next, jumper" :total="form.total" @size-change="handleSizeChange" @current-change="handleCurrentChange" />
        </div>
    </div>

    <el-dialog v-model="isEdit" title="审核管理" width="30%">
        <component :is="reviewForm" :data = editInfo />
    </el-dialog>
</template>

<script lang="ts" setup>
import { ref,onMounted } from 'vue'
import { RefreshRight, Search } from '@element-plus/icons-vue'
import reviewForm from './components/reviewForm.vue';
import { ElMessage } from 'element-plus'
const indexMethod = (index: number) => {
  return index+= 1
}
const form = ref<any>({search:'',page:0,current:0,total:10,limit:20,loading:false,parentBorder:false})
const isEdit = ref<boolean>(false)
interface info {
    id: number
    type:string
    schedule_title: string //进度名称/工序名称
    project_title: string //项目名称
    project_user:string //进度责任人姓名
    region: string //区域
    floor : string //楼层
    tpm: string //维护方
    tpm_user: string //维护人
    delay: string //推迟原因
    created_at: string //提交时间
}
const editInfo = ref<info>()
const tableData = ref<info[]>([])

const onGetData = () => {
    console.log('请求')
    form.value.page = 0;
    form.value.loading = true
    tableData.value = [
        {id:1,type:'维护结果',schedule_title:'进度/工序名称',project_title:'项目名称',region:'区域',created_at:'2020-11-22',floor:'楼层',project_user:'进度责任人',tpm:'维护方',tpm_user:'维护人',delay:'推迟原因'},

    ]
    form.value.loading = false
    // form.value.loading = true
    // http.post('/Disclosure',form.value).then((response:any)=>{
    //     form.value.loading = false
    //     tableData.value = response.data.data
    //     form.value.total = response.data.total
    // })
}

const onSearch = (type = '') => {
    if(type == 'Refresh'){
        form.value.search = ''
        onGetData()
        return
    }
    if(!form.value.search){
        ElMessage.error('请输入搜索内容')
    }
    onGetData()
}


const onReview = (data: number) => {
    editInfo.value = tableData.value[data]
    isEdit.value = true
}

const handleSizeChange = (val: number) => {
    form.value.limit = val
}
const handleCurrentChange = (val: number) => {
    form.value.page = val
}
onMounted(()=>{
    onGetData()
})

</script>

<style scoped>

</style>